package com.example.chenjun.myapplication.net.okhttp.request;

import android.support.annotation.NonNull;

import java.util.Map;
import java.util.Set;

import okhttp3.FormBody;
import okhttp3.RequestBody;

public class PostFormRequest extends OkHttpRequest {
    public PostFormRequest(Map<String, String> params, Map<String, String> headers, @NonNull String url, String tag) {
        super(params, headers, url, tag, "POST");
    }

    @Override
    protected RequestBody buildRequestBody() {
        FormBody.Builder builder = new FormBody.Builder();
        Set<String> paramKeySet = params.keySet();
        for (String key : paramKeySet) {
            builder.add(key, params.get(key));
        }
        return builder.build();
    }
}
